package com.medical.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.medical.entity.SysUser;
import com.medical.service.UserService;

@Controller
public class LoginController {
	@Autowired
	private UserService userService;
	
	@RequestMapping("/login")
	public String login(Integer userId, String userPassword, Model model) {
		
		SysUser sysUser = userService.findUserByUserId(userId);
		
		if(sysUser != null && sysUser.getUserPassword().equals(userPassword)) {
			model.addAttribute(sysUser);
			return "main";
		}
		
		return "../../index";
	}
	
	@RequestMapping("/openWelcomePage")
	public String openWelcomePage(Model model) {
		return "welcome";
	}
}
